<template>
	<view>
		<view class="input-box">
			<input class="iput cwhite" @input="input"  placeholder="请输入修改昵称" />
		</view>
		
		<view class="btn">
			<button @click="toEdit" class="cwhite themeBac">确定修改</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				name:""
			}
		},
		methods: {
			toEdit(){
				console.log(this.name);
				if(this.name.trim()===''){
					this.$u.toast("请先输入修改昵称！")
					return
				}
				this.updateConsumer()
			},
			input(value){
				this.name=value.detail.value
			},
			async updateConsumer(){
				const res = await this.$u.api.updateConsumer({
					id:this.vuex_user.id,
					name:this.name
				})
				console.log(this.vuex_user);
				this.vuex_user.name=this.name
				res.success?this.$back(1):this.$u.toast(res.msg)
			}
		}
	}
</script>

<style>
.input-box{
	margin: 30rpx 40rpx;
}

.iput{
	background-color: #9A9A9A;
	height: 80rpx;
	border-radius: 10rpx;
	text-indent: 1em;
}

.uni-input-placeholder{
	color: #FFFFFF;
}

.btn{
	margin: 150rpx 80rpx;
}
</style>
